<template>
	<view class="content">
		<view class="top_box">
			<!-- <view class="no_user">
				<view class="img">
					<image src="/static/logo.png" mode=""></image>
				</view>
				<view class="img">
					<image src="/static/logo.png" mode=""></image>
				</view>
				<image src="/static/ww.png" mode="" class="more"></image>
				<image src="/static/g2.png" mode="" class="more"></image>
			</view> -->
			<view class="user">
				<view class="img" v-for="item in info.groupDetails">
					<image :src="item.pic" mode=""></image>
				</view>
			</view>
			<view class="tip" v-if="info.groupStatus == 3">
				很遗憾，只差{{info.miniNum - info.involved}}人拼单成功
			</view>
			<view class="tip" v-if="info.groupStatus == 2">
				拼单成功
			</view>
			<view class="tip" v-if="info.groupStatus == 1">
				拼单中，邀请好友加快进度
			</view>
			<view class="btn" v-if="info.groupStatus == 3">
				再次发起
			</view>
			<view class="btn" v-if="info.groupStatus == 2">
				继续逛逛
			</view>
			<button  open-type="share" class="btn" v-if="info.groupStatus == 1">
				邀请好友
			</button>
		</view>
		<view class="orderInfo">
			<view class="title">
				订单信息
			</view> 
			<view class="item">
				<text class="text">订单编号</text>
				 <text class="num">{{info.ownerPayInfo.orderId}}</text>
				<view class="copy" @click="handleCopy">复制</view>
			</view>
			<view class="item">
				<text class="text">拼单时间</text> <text class="num">{{info.ownerPayInfo.createTime}}</text>
			</view>
			<view class="item">
				<text class="text">付款时间</text> <text class="num">{{info.ownerPayInfo.payTime}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				info:'',
				goods_num: 1,
				order_id:'',
				o_payment_time:'',
				o_create_time:'',
				orderInfo: {
					list:[{
						good_title:'迪奥马鞍包单肩包',
						price:'20999',
						number:'2',
						cate:'蓝色'
					}],
					price_total:'20999',
					yhq:'100',
					yf:'10',
					yfk:'20000',
					order_desc:'备注信息',
					order_no:'LEETA218745956908',
					createtime_text:'2025-01-12 13:12:45',
					pay_time_text:'2025-01-12 13:18:20',
					status:0
				},
				bottomPadding: 0
			}
		}, 
		onShareAppMessage: function (res) {
		   return { 
				imageUrl:this.info.product.pic,
				title:`${this.userInfo.nickname}邀请您拼单`,
				path: `/pagesA/group/detail?id=${this.info.id}`
		   };
		},
		computed: {
			userInfo() {
				return this.$store.state.userInfo 
			}
		},
		onLoad(option) { 
			this.id = option.id
			this.getDetail()
		},
		methods:{
			getTime(o_create_time){ 
				
				// 创建 Date 对象
				const date = new Date(o_create_time);
				
				// 提取年、月、日、时、分、秒
				const year = date.getFullYear();
				// 月份从 0 开始，所以要加 1
				const month = String(date.getMonth() + 1).padStart(2, '0'); 
				const day = String(date.getDate()).padStart(2, '0');
				const hours = String(date.getHours()).padStart(2, '0');
				const minutes = String(date.getMinutes()).padStart(2, '0');
				const seconds = String(date.getSeconds()).padStart(2, '0');
				
				// 拼接成最终格式
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
				 
			},
			handleCopy(){
				uni.setClipboardData({
					data: this.info.ownerPayInfo.orderId,
					success: function () {
						uni.showToast({
							title:"复制成功",
							icon:"none"
						})
					},
					fail: (e) => {
						console.log('eeee',e)
					}
				});
			},
			getDetail(){
				this.$http({
					url:"/pmsGroupDetail/groupOrderInfoByOrderSn",
					method:"get",
					data:{
						orderSn:this.id
					}
				}).then(data=>{
					this.info = data
					if(data.groupStatus == 1){
						uni.setNavigationBarTitle({
							title:"邀请拼单"
						})
					}else if(data.groupStatus == 2){
						uni.setNavigationBarTitle({
							title:"拼单成功"
						})
					}else if(data.groupStatus == 3){
						uni.setNavigationBarTitle({
							title:"拼单失败"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding: 30rpx;
		box-sizing: border-box;
	}
	.orderInfo {
		background: #fff;
		margin-top: 50rpx; 
		.title{
			font-size: 30rpx;
			font-weight: bold;
			margin-bottom: 20rpx;
		}
		.item {
			height: 60rpx;
			display: flex;
			align-items: center;
	
			.text {
				font-size: 24rpx;
				color: #666;
			}
	
			.num {
				font-size: 24rpx;
				color: #666;
				margin-left: 20rpx;
			}
	
			.copy {
				font-size: 24rpx;
				color: #333;
				margin-left: 20rpx;
			}
		}
	}
	.top_box{
		background: #F8F8F8;
		padding: 40rpx 0 30rpx 0;
		.btn{
			width: 240rpx;
			height: 73rpx;
			background: #020202;
			border-radius: 50rpx;
			text-align: center;
			line-height: 73rpx;
			font-size: 26rpx;
			color: #fff;
			margin: 0 auto;
			margin-top: 40rpx;
		}
		.tip{
			text-align: center;
			font-size: 24rpx;
			color: #333333;
			margin-top: 50rpx;
		}
		.user{
			display: flex;
			flex-wrap: wrap;
			justify-content: center;
			.img{
				width: 92rpx;
				height: 92rpx;
				margin: 0 18rpx;
				position: relative;
				image{
					width: 92rpx;
					height: 92rpx;
					border: 2px solid #333;
					display: block;
					border-radius: 50%;
				}
			}
		}
		.no_user{
			display: flex;
			flex-wrap: wrap;
			justify-content: center;
			.more{ 
				width: 94rpx;
				height: 94rpx;
				display: block;
				margin: 0 18rpx;
			}
			
			text{
				display: block;
				width: 66rpx;
				height: 28rpx;
				background: #020202;
				border-radius: 14rpx;
				position: absolute;
				left: 0;
				right: 0;
				margin: 0 auto;
				bottom: -20rpx;
				color: #fff;
				text-align: center;
				line-height: 28rpx;
				font-size: 20rpx;
			}
			.img{
				width: 92rpx;
				height: 92rpx;
				margin: 0 18rpx;
				position: relative;
				image{
					width: 92rpx;
					height: 92rpx;
					display: block;
					border: 2px solid #333;
					border-radius: 50%;
				}
			}
		}
	}
</style>